﻿using System.Collections.Generic;
using System.Linq;
using DataBaseLayer.Dto;

namespace DataBaseLayer.Extensions
{
	public static class LogOrderEx
	{
		public static LogOrderData ToDto(this LogOrder entity)
		{
			if (entity == null) return null;

			var dto = new LogOrderData
			{
				Date = entity.Date,
				Description = entity.Description,
				Id = entity.Id,
				Number = entity.Number,
				Performer = entity.Performer
			};

			return dto;
		}

		public static IEnumerable<LogOrderData> ToDtos(this IEnumerable<LogOrder> entities)
		{
			return entities != null ? entities.Select(e => e.ToDto()).ToList() : null;
		}
	}
}
